<template>
  <div class="sharedetail">
    <van-nav-bar title="分享该内容，开启赚钱之路！" fixed @click-right="clickRight">
      <div slot="right">
        <img class="img" src="../../assets/detail_share.png" />
        <span class="share">分享</span>
      </div>
    </van-nav-bar>
    <div class="content" :style="{
        height: infoData.card ? 'calc(100vh - 46vw)' : 'calc(100vh - 15vw)',
      }">
      <h3 style="text-align:center;margin-top:20px">{{ infoData.title }}</h3>
      <div class="con" v-html="infoData.content"></div>
      <span class="conspan">{{ infoData.copyright }}</span>
      <!-- 公众号 -->
      <div class="public" v-if="infoData.attention">
        <img :src="infoData.attentionUrl" alt="" />
      </div>
      <!-- 点赞收藏浏览量 -->
      <div class="foot">
        <span @click="like = !like">
          <i class="iconfont" :class="{ 'icon-dianzan1': like, 'icon-dianzan': !like }" :style="{ color: like ? 'red' : '' }"></i>
          点赞
        </span>
        <span @click="collect = !collect">
          <i class="iconfont" :class="{ 'icon-shoucang1': collect, 'icon-shoucang': !collect }" :style="{ color: collect ? 'red' : '' }"></i>
          收藏
        </span>
        <span>
          <i class="iconfont icon-liulan"></i>
          浏览 {{infoData.score}}
        </span>
      </div>
      <van-divider />

      <div class="btn" v-if="infoData.notType==false" @click="addZhaoPinziliao">
        <span>投递简历</span>
      </div>
      <div class="btns" v-else>
        <span>已投递</span>
      </div>
      <div class="contentsss">
        <div class="contents-title">
          <div class="content-left">
            <img src="../../assets/images/invite/shu.png" alt="">
            <span>招聘列表</span>
          </div>
        </div>
        <div class="contents-center" v-if="recruitmentArr.length">
           <van-list
              v-model="loading"
              :finished="finished"
              finished-text="没有更多了"
              @load="onLoad"
            >
            <van-cell-group v-for="(item,index) in recruitmentArr" :key="index" @click="$router.push({path:'/recruitmentdetails',query:{id:item.id}})">
              <div class="contents-center-item">
                <div class="imgs">
                  <img src="../../assets/images/task/getMoney.png" alt="" class="money" v-show="item.type == 9" />
                  <img :src="item.cover" alt="">
                </div>
                <div class="contents-b-item">
                  <div class="left">
                    <div class="title">
                      <h3>{{item.title}}</h3>
                    </div>
                    <div class="content">
                      <p>{{item.describes}}</p>
                    </div>
                    <div class="contents-text">
                      <div class="contents-text-item">
                        <img src="../../assets/images/invite/fenxiang.png" alt="">
                        <p>转发：{{item.share || 0}}次</p>
                      </div>
                      <div class="contents-text-item">
                        <img src="../../assets/images/invite/yuedu.png" alt="">
                        <p>阅读：{{item.score || 0}}次</p>
                      </div>
                      <div class="contents-text-item">
                        <p style="margin-top:2px">{{item.gmtCreate.substring(0,11)}}</p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </van-cell-group>
           </van-list>
        </div>
        <van-empty description="当前暂无招聘内容~" class="custom-image" :image="require('../../assets/dafault/noinvite.png')" v-else>
        </van-empty>
      </div>
    </div>

    <!-- 弹框 -->
    <div class="overlay" v-show="show"></div>
    <div class="dialog" v-show="show">
      <img src="../../assets/images/detail/detail_img.png" alt="" class="dialog_img" />
      <h3>完善个人信息</h3>
      <p>完善信息后，可以将完善的信息在 分享文章中显示。</p>
      <div class="foot">
        <button @click="perfectClick(1)">去完善</button>
        <button @click="perfectClick(2)">直接分享</button>
      </div>
      <div class="close" @click="show = false">
        <img src="../../assets/images/detail/detail_close.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
import sdk from "../../plugins/wxshare";
import extract from "../../plugins/extract";

export default {
  data () {
    return {
      loading: false, //加载状态
      finished: false, //完成
      page: 1, //页数
      limit: 8, //条数
      totalPage: "", //总页数
      show: false, //弹框
      id: "",
      getPhoneObj: "", //获取微信权限信息
      infoData: {},
      recruitmentArr: [],//简历列表
      name: "", //姓名
      phone: "", //手机号
      remark: "", //备注
      code: "", //验证码
      count: 60, //倒计时
      timer: null,
      isCode: false,
      // 微信分享
      wxShareObj: {
        showShare: false,
        title: "",
        text: "",
        img: "",
        getShareUrl: "",
        show: false,
      },
      like: false, //点赞
      collect: false, //收藏
      flag: true, //重复请求节流
      userId: "",
    };
  },
  created () {
    sdk.setTitle("招聘详情");
  },

  async mounted () {
    this.getRecruits();
    if (!JSON.parse(sessionStorage.getItem("userWxData"))) {
      this.getPhoneObj = await extract.wxShare();
    } else {
      this.getPhoneObj = JSON.parse(sessionStorage.getItem("userWxData"));
    }

    // 文章数据
    if (this.getPhoneObj) this.gettingData();
  },
  methods: {
       //触底下一页
    onLoad() {
      if (this.page >= this.totalPage) {
        this.finished = true;
        return;
      }
      this.page++;

      this.getRecruits();
      // 加载状态结束
      this.loading = false;
    },
    // 获取招聘-招聘推广
    async getRecruits () {
      let obj = {
        account: sessionStorage.getItem("agentId"),
        title: "",
        status: 2,
        page:this.page,
        limit:this.limit
      }
      let res = await this.$api.getRecruit(obj);
          //判断是否是第一页
      if (this.page == 1) {
        this.recruitmentArr = res.data.list || [];
      } else {
        this.recruitmentArr.push(...res.data.list);
      }
      this.totalPage = res.data.totalPage;
    },
    addZhaoPinziliao () {
      this.$router.push({
        path: "/resume",
        query: {
          id: this.infoData.id,
          tableId: this.$route.query.tableId,
          userId: this.$route.query.userId,
          account: this.$route.query.account,
          shareId: this.$route.query.shareId
        }
      })
    },
    //完善分享
    perfectClick (n) {
      this.show = false;
      if (n == 1) {
        this.$router.push("/personal?ids=" + this.$route.query.id);
      } else {
        this.$router.push({
          path: `/recruitmentedit?id=${this.$route.query.tableId}&userId=${this.userId}&tableId=${this.$route.query.tableId}`,
        });
      }
    },
    //点击分享
    async clickRight () {
      if (this.type == 9) {
        //判断是否有分享次数
        let obj = {
          id: this.$route.query.tableId,
          tableType: 3,
          type: 9,
        };
        var result = await this.$api.checkingSpreadShare(obj);
      }
      if (this.type == 9 && !result.status) {
        return this.$toast("您不能分享该招聘！");
      }

      let res = await this.$api.checkUserInfo(this.userId);
      if (res.code != 0) {
        this.show = true;
        return;
      }
      this.$router.push({
        path: `/recruitmentedit?id=${this.$route.query.tableId}&userId=${this.userId}&tableId=${this.$route.query.tableId}`,
      });
    },
    //请求招聘数据
    gettingData () {
      this.$publicObj.getLoading(); //加载
      let userInfo = JSON.parse(sessionStorage.getItem("userWxData"));

      let obj = {
        id: this.$route.query.tableId,
        tableId: this.$route.query.tableId,
        openId: userInfo.openid,
        name: this.getPhoneObj.nickname,
        image: this.getPhoneObj.headimgurl,
        shareId: this.$route.query.shareId,
        userId: this.$route.query.userId,
        tableType: 15,
        sex: this.getPhoneObj.sex,
        city: this.getPhoneObj.city,
        province: this.getPhoneObj.province,
        account: this.$route.query.account,
        customerId: sessionStorage.getItem("agentIds")
      };

      this.$api.getArticleShareInfo(obj).then((res) => {
        this.$publicObj.closeLoading();
        this.infoData = res.data;
        this.userId = res.data.userId;
        sessionStorage.setItem("changeTitle", res.data.changeTitle);
        sessionStorage.setItem("shareId", res.data.userId);
        sessionStorage.setItem("agentId", this.$route.query.account);
        sessionStorage.setItem("agentIds", res.data.userId);
        sessionStorage.setItem("description", this.infoData.describes);
        sessionStorage.setItem("title", this.infoData.title);
        sessionStorage.setItem("article_img", this.infoData.cover);
      })
        .catch((err) => {
          this.$publicObj.closeLoading();
          console.log(err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
.contentsss {
  padding-bottom: 50px;
  .contents-title {
    display: flex;
    justify-content: space-between;
    .content-left {
      display: flex;
      padding: 8px 8px;
      img {
        width: 4px;
        height: 20px;
      }
      span {
        margin: 0.5px 10px;
        font-size: 14px;
        color: #3b447a;
      }
    }
  }
  .contents-center {
    .contents-center-item {
      display: flex;
      padding: 12px;
      border-bottom: 1px solid ghostwhite;
      .imgs {
        flex: 1;
        width: 90px;
        height: 90px;
        margin-right: 15px;
        position: relative;
        img {
          width: 100%;
          height: 100%;
          border-radius: 5px;
        }
        .money {
          width: 35px;
          height: 35px;
          position: absolute;
          right: 0;
          top: 0;
          border-radius: none;
        }
      }
      .contents-b-item {
        flex: 3;
        .left {
          .title {
            h3 {
              display: block;
              font-size: 14px;
              color: #333333;
            }
          }
          /deep/ .content {
            padding: 0 0;
            margin-top: 2px;
            p {
              font-size: 11px;
              color: #999999;
              height: 30px;
              display: -webkit-box;
              overflow: hidden;
              -webkit-box-orient: vertical;
              text-overflow: ellipsis;
              -webkit-line-clamp: 2;
            }
          }
          .bottom {
            display: flex;
            margin-top: 8px;
            justify-content: space-between;
            .lefts {
              display: flex;
              img {
                width: 40px;
                height: 20px;
              }
              .img2 {
                margin-left: 12px;
              }
            }
            .rights {
              margin-right: 12px;
            }
          }
          .contents-text {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            color: #999;
            .contents-text-item {
              display: flex;
              justify-content: space-between;
              margin-top: 10px;
              img {
                width: 12px;
                height: 12px;
                margin-top: 2px;
              }
              p {
                margin-left: 5px;
              }
            }
          }
        }
      }
    }
  }
}
.btns {
  width: 80%;
  height: 42px;
  opacity: 1;
  background: #edf1f4;
  border-radius: 41px;
  color: #fff;
  text-align: center;
  line-height: 42px;
  margin: 0 auto;
}
.btn {
  width: 80%;
  height: 42px;
  opacity: 1;
  background: #477fe6;
  border-radius: 41px;
  color: #fff;
  text-align: center;
  line-height: 42px;
  margin: 40px auto;
}
.content {
  box-sizing: border-box;
  // height: calc(100vh - 215px);
  padding: 66px 15px 20px;
  position: relative;
  overflow-y: scroll;

  h3 {
    color: #141414;
    font-size: 20px; 
    font-weight: 700;
    margin-bottom: 10px;
  }
  .con {
    font-size: 12px;
    color: #333333;
    line-height: 24px;
    img {
      height: 171px;
      width: 100%;
      margin: 15px 0 22px 0;
    }
  }
  .conspan {
    float: right;
    font-size: 11px;
    color: #666666;
  }
  .public {
      margin-top: 35px;
      position: relative;
      background: url('../../assets/images/detail/zzh_bg.png') no-repeat;
      background-size: 100%;
      width: 100%;
      height: 138px;
      img {
        position: absolute;
        width: 70px;
        height: 70px;
        left: 210px;
        top: 20px;
      }
    }
  .foot {
    margin-top: 20px;
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #6c7592;
    justify-content: space-between;
    span {
      &:nth-of-type(2) {
        margin-right: 155px;
      }
    }
  }
  .form {
    height: 350px;
    background-color: #fbfcff;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;

    h3 {
      background: url('../../assets/images/detail/head_g.png') no-repeat;
      background-size: contain;
      background-position: center;
      width: 178px;
      font-size: 17px;
      font-weight: 700;
      text-align: center;
      color: #000000;
      margin-top: 18px;
    }
    .forms {
      margin-top: 14px;
      padding: 0 15px;
      box-sizing: border-box;
      .item {
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        position: relative;
        .code {
          position: absolute;
          right: 6px;
          top: 6px;
          display: flex;
          justify-content: center;
          align-items: center;
          width: 60px;
          height: 21px;
          background-color: #ff8571;
          border-radius: 5px;
          font-size: 11px;
          color: #ffffff;
        }
        label {
          font-size: 14px;
          color: #000000;
          width: 63px;
          height: 20px;
          margin-right: 24px;
          span {
            color: red;
          }
        }
        input {
          font-size: 12px;
          padding: 8px 0 9px 16px;
          width: 227px;
          box-sizing: border-box;
          height: 34px;
          background: #ffffff;
          border: 1px solid #999999;
          border-radius: 5px;
          &::placeholder {
            color: #999999;
          }
        }
        textarea {
          font-size: 12px;
          padding: 8px 0 9px 16px;
          box-sizing: border-box;
          width: 228px;
          height: 91px;
          background-color: #ffffff;
          border: 1px solid #999999;
          border-radius: 5px;
          &::placeholder {
            color: #999999;
          }
        }
      }
    }
    .btn {
      width: 100%;
      height: 40px;
      background-color: #0264d1;
      border-radius: 0px 0px 5px 5px;
      font-size: 14px;
      font-weight: 700;
      color: #ffffff;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .forms {
    width: 100%;
    height: 270px;
    img {
      width: 100%;
      height: 100%;
    }
  }

  .user {
    background-color: #edf1f4;
    display: flex;
    padding: 0 4vw;
    background: url('../../assets/images/detail/ewm_bg.png') no-repeat;
    background-size: 100%;
    box-sizing: border-box;
    height: 140px;
    width: 345px;
    position: fixed;
    left: 15px;
    bottom: 50px;
    color: #e2e2e2;
    .userimg {
      width: 104.5px;
      height: 80px;
      margin: 20px 0 0 30px;
      border-radius: 5px;
    }
    .right {
      margin-left: 9px;
      margin-top: 22.5px;
      h4 {
        font-size: 11px;
        margin-bottom: 12px;
      }
      span {
        width: 140px;
        display: flex;
        align-items: center;
        font-size: 9px;
        margin-bottom: 8px;
        line-height: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        img {
          width: 8px;
          height: 8px;
        }
      }
      p {
        margin-top: 20px;
        font-size: 8px;
        color: #b8b8b8;
        text-align: right;
        padding-right: 6px;
      }
    }
    .ewm {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;
      img {
        margin-bottom: 16px;
        width: 43px;
        // height: 43px;
      }
    }
  }
}

.img {
  width: 14px;
  height: 14px;
  margin-right: 4px;
}
.share {
  font-size: 14px;
  color: #707070;
}
.dialog {
  position: fixed;
  z-index: 2002;
  top: 50%;
  left: 50%;
  -webkit-transform: translate3d(-50%, -50%, 0);
  transform: translate3d(-50%, -50%, 0);
  width: 268px;
  height: 271px;
  background: url('../../assets/images/detail/detail_bg.png') no-repeat;
  background-size: 100% 100%;
  .dialog_img {
    width: 124px;
    height: 127px;
    position: absolute;
    left: 71.5px;
    top: -47px;
    z-index: 2003;
  }
  h3 {
    font-size: 16px;
    font-weight: 700;
    color: #333333;
    margin-top: 120px;
    margin-bottom: 10px;
    text-align: center;
  }
  p {
    font-size: 14px;
    color: #666666;
    padding: 0 29px;
  }
  .foot {
    margin-top: 34px;
    padding: 0 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    button {
      width: 90px;
      height: 32px;
      background: linear-gradient(90deg, #fcaf36 1%, #fe774c);
      border-radius: 16px;
      color: #fff;
      border: none;
      &:last-of-type {
        border: 1px solid #fd7c49;
        color: #fd7c4a;
        background: #fff;
      }
    }
  }
  .close {
    width: 35px;
    height: 35px;
    position: absolute;
    bottom: -50px;
    left: 116px;
    z-index: 2004;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background-color: rgba(90, 90, 90, 0.5);
}
</style>
